package com.zy.openchat.core.model.message;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;
import java.util.List;

public class FormatTextInfo implements Parcelable {
    public String text;
    public List<TextEntity> entities;

    public FormatTextInfo(String text) {
        this.text = text;
        this.entities = new ArrayList<>();
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.text);
        dest.writeTypedList(this.entities);
    }

    public void readFromParcel(Parcel source) {
        this.text = source.readString();
        this.entities = source.createTypedArrayList(TextEntity.CREATOR);
    }

    public FormatTextInfo() {
    }

    protected FormatTextInfo(Parcel in) {
        this.text = in.readString();
        this.entities = in.createTypedArrayList(TextEntity.CREATOR);
    }

    public static final Parcelable.Creator<FormatTextInfo> CREATOR = new Parcelable.Creator<FormatTextInfo>() {
        @Override
        public FormatTextInfo createFromParcel(Parcel source) {
            return new FormatTextInfo(source);
        }

        @Override
        public FormatTextInfo[] newArray(int size) {
            return new FormatTextInfo[size];
        }
    };
}
